package com.xxzx.journalism.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxzx.journalism.entity.Navs;
import com.xxzx.journalism.mapper.NavsMapper;
import com.xxzx.journalism.model.vo.info.NavVO;
import com.xxzx.journalism.service.NavsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 */
@Service
public class NavsServiceImpl extends ServiceImpl<NavsMapper, Navs> implements NavsService {

    @Autowired
    NavsMapper navsMapper;

    /**
     * 导航列表
     *
     * @return
     */
    @Override
    public List<NavVO> getNavs() {
        List<Navs> navs = navsMapper.selectList(new QueryWrapper<Navs>().orderByAsc("sort"));
        List<NavVO> navVO = new ArrayList<>();
        navs.forEach((info) -> {
            NavVO navVo = new NavVO();
            BeanUtils.copyProperties(info, navVo);
            navVO.add(navVo);
        });
        return navVO;
    }
}
